<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="/struts-dojo-tags"prefix="sx"%>
<%@ taglib prefix="s" uri="/struts-tags"%>


<html>
	<head>
		<title>Project</title>
		<link rel="stylesheet" type="text/css" href="${ pageContext.request.contextPath }/css/common.css">
		<link rel="stylesheet" href="${ pageContext.request.contextPath }/css/jquery-ui.css" />
		<script type="text/javascript" src="${ pageContext.request.contextPath }/js/jquery-1.6.2.js"></script>
		<script type="text/javascript" src="${ pageContext.request.contextPath }/js/jquery-ui-1.8.18.custom.min.js"></script>
		<script type="text/javascript" src="${ pageContext.request.contextPath }/js/jquery.form.js"></script>
		<script type="text/javascript">
		$(document).ready(function() {
		    $( "#sttm" ).datepicker({showButtonPanel: true ,dateFormat : "yy-mm-dd"});
		    $( "#endtm" ).datepicker({showButtonPanel: true ,dateFormat : "yy-mm-dd"});
		    
		    $("#changeLogo").click(function(){
		      if($("#uploadLogo").is(":visible")){
		    	  $("#uploadLogo").css("display","none");
		    	  $("#changeLogo").text("更换");
		      }
		      else{
		    	  $("#uploadLogo").slideDown('slow');
		          $("#changeLogo").text("取消");}       
		    });
		    
		    $("#uploadLogo").change(function(){
		    	var options={
		    			url: "http://localhost:8088/scrumfriend/project/changeProjectLogo.action",
		    			type: "post",
		    			dataType : "json", 
		    			success : function(data){
		    				$("#projectLogo").attr("src","${ pageContext.request.contextPath }/"+data.updatedLogoPath);
		    				$("#uploadLogo").css("display","none");
		    				$("#changeLogo").text("更换");
		    				$("#updateProject_attachmentId").attr("value",data.attachmentId);
		    				
		    			}
		    	} 	
		    	
		    	$("#updateProject").ajaxSubmit(options);
		    });
		    		    
		});
		</script>
	</head>

	<body>
	<s:form name="updateProject" action="updateProject" method="POST" theme="simple" enctype="multipart/form-data">
	  <s:hidden name="project.id" value="%{project.id}"></s:hidden>
	  <s:hidden name="userId" value="%{project.user.id}"></s:hidden>
	  <s:hidden name="attachmentId" value="%{project.logo.id}"></s:hidden>
		<fieldset>
				<legend>项目</legend>
				<table id="project_tb" >
					<tr>
						<td>
						<s:label>项目名称：</s:label>
						<s:textfield name="project.name"></s:textfield>
						</td>					
					</tr>
					<tr>
					    <td>
					    <s:label>Logo：</s:label>
						    <s:if test="%{project.logo==null}">						     
							   <img src='${ pageContext.request.contextPath }/images/green.jpg'>			
							</s:if>
							<s:else>
							   <img src='${ pageContext.request.contextPath }/<s:property  value="%{project.logo.path}"/>'  width="60px" height="80px" id="projectLogo">
							</s:else>
							<a href="#" id="changeLogo">更改</a>
							<s:file id="uploadLogo" name="image" class="uploadLogo" ></s:file>
	
					    </td>
					</tr>
					<tr>
						<td>
						<s:label>项目愿景：</s:label>
						<s:textarea name="project.description"  rows="4" cols="50"></s:textarea>
						</td>
					</tr>
					<tr>
						<td>
						<s:label>开始时间：</s:label>
						<s:textfield name="project.start_time" id="sttm"></s:textfield>
						</td>
						<td>
						<s:label>结束时间：</s:label>
						<s:textfield name="project.end_time" id="endtm"></s:textfield>
						</td>
					</tr>
					<tr>
						<td>
						<s:submit value="提交"></s:submit>
						</td>
					</tr>
				</table>
		</fieldset>
		</s:form>
	</body>
</html>
